package com.itheima.web.listener;

import com.itheima.domain.db.Log;
import com.itheima.service.db.LogService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component//日志监听器
@RocketMQMessageListener(consumerGroup = "user-log-group",topic = "tanhua-user-log")//绑定topic
//当topic添加数据 运行程序
public class LogListener implements RocketMQListener<Log> {
    @DubboReference
    private LogService logService;
    @Override  //把添加的数据添加到数据库
    public void onMessage(Log log) {
    logService.saveLog(log);
    }
}
